cmake_minimum_required(VERSION 3.10)

project(RemoteControl)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
find_package(wxWidgets REQUIRED COMPONENTS net core base)
find_package(fmt REQUIRED)
find_package(lz4 REQUIRED)
find_package(oatpp REQUIRED)
find_package(oatpp-websocket REQUIRED)
include(${wxWidgets_USE_FILE})

file(GLOB SourceCode "src/*.cpp" "src/*.h")

add_executable(RemoteControl ${SourceCode} ../../src/Image8BitConver.cpp)

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
  message("You are using debug profile.")
  target_compile_options(
    RemoteControl
    INTERFACE
      "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-ggdb;-O0;-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>>"
  )
else()
  message("You are using release profile.")
  if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
    message("Enable optimize for aarch64")
    target_compile_options(
      RemoteControl
      INTERFACE
        "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-O3;-ftree-vectorize;–mfpu=neon;-Wall>>"
    )
  elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "armv7l")
    message("Enable optimize for aarch64")
    target_compile_options(
      CameraTest
      INTERFACE
        "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-O3;-ftree-vectorize;–mfpu=neon;-Wall>>"
    )
    set(CameraLib ${CameraLib_armhf})
  else()
    target_compile_options(
      RemoteControl INTERFACE "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-O3;-Wall>>")
  endif()

endif()

target_include_directories(
  RemoteControl PUBLIC "inc" "/usr/local/include/oatpp-1.3.0/oatpp/"
                       "/usr/local/include/oatpp-1.3.0/oatpp-websocket")
target_link_libraries(
  RemoteControl PUBLIC ${wxWidgets_LIBRARIES} oatpp::oatpp
                       oatpp::oatpp-websocket fmt pthread lz4)
